import 'package:flutter/material.dart';
import 'dart:async' show Future;
import 'package:flutter/services.dart' show rootBundle;

class AssetsDemo extends StatefulWidget {
	@override
	State<StatefulWidget> createState() {
		return AssetsDemoState();
	}
}

class AssetsDemoState extends State<AssetsDemo> {

	String text = "Empty";
	String widgets = "";

	@override
	Widget build(BuildContext context) {
		return Scaffold(
			appBar: AppBar(title: Text("AssetsDemo"),
			),
			body: Center(
				child: _createBody(),
			),
		);
	}

	Widget _createBody() {
		return new Column(
			children: <Widget>[
				RaisedButton(
					child: Text("Load Assets"),
					onPressed: () {
						_startLoadAssets();
					},
				),
				RaisedButton(
					child: Text("StopLoadData"),
					onPressed: () {

					},
				),
				Text(text),
			],
		);
	}

	Future<String> _startLoadAssets() async {
		String data = await rootBundle.loadString("assets/my-assets/data.json");
		setState(() {
			text = data;
		});
		return data;
	}
}